﻿using Mimas.Framework.Server.UserManagement;
using Mimas.Framework.Shared.Data.CriteriaObjects;
using Mimas.Framework.Shared.Data.DataTransferObjects;
using Mimas.Framework.Shared.Data.EnumObjects;
using System.Collections.Generic;
using System.Web;
using System.Linq;
using Mimas.Core.Current;
using Mimas.Core.Utility;

namespace Mimas.Framework.Server.Security
{
  public static class SecurityManagementBL
  {
    public static MenuItemDTO[] GetMyAccessableMenuItems()
    {
      List<MenuItemDTO> result = new List<MenuItemDTO>();

      result = Toolkit.CloneStaticItems<List<MenuItemDTO>>(Constants.MenuItems.ToList());

      int[] MenuItemIds = Constants.AccessLists.Where(x => x.UserType == UserInfo.CurrentUser.UserType && x.IsAccessable.HasValue && x.IsAccessable == true).Select(x => x.MenuItemId).Distinct().ToArray();

      result = result.Where(x => MenuItemIds.Contains(x.Id)).ToList();

      return result.ToArray();
    }



  }
}
